Crate pin_project
source · [−]Expand description
A crate for safe and ergonomic pin-projection.
Examples
#[pin_project]
attribute creates projection types
covering all the fields of struct or enum.
use std::pin::Pin;
use pin_project::pin_project;
#[pin_project]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
impl<T, U> Struct<T, U> {
fn method(self: Pin<&mut Self>) {
let this = self.project();
let _: Pin<&mut T> = this.pinned; // Pinned reference to the field
let _: &mut U = this.unpinned; // Normal reference to the field
}
}
code like this will be generated
See #[pin_project]
attribute for more details, and
see examples directory for more examples and generated code.
Traits
A trait used for custom implementations of Unpin
.
This trait is used in conjunction with the UnsafeUnpin
argument to #[pin_project]
Attribute Macros
An attribute that creates projection types covering all the fields of struct or enum.
An attribute for annotating an impl block that implements Drop
.
(deprecated) An attribute to provide way to refer to the projected type returned by
project
method.
(deprecated) An attribute to provide way to refer to the projected type returned by
project_ref
method.
(deprecated) An attribute to provide way to refer to the projected type returned by
project_replace
method.